Ext.define('CS.plugin.PanelDataDeal', {
	extend: 'CS.plugin.BasePlugin',

	ignoreExist: true,

	extFn: {
		getData: function(notNeedCls) {
			var data = {};

			if (this.isForm) {
				this.items.each(function(item) {
					var cls = item.clsName, name = item.clsParam;

					if (CS.isNull(cls) || notNeedCls == true) {
						data[name] = item.getData();
					} else {
						if (CS.isNull(data[cls])) {
							data[cls] = {};
						}

						data[cls][name] = item.getData();
					}
				});
			} else {
				Ext.each(this.children(), function(item) {
					if (CS.isNotNull(item.getData)) {
						data = Ext.merge(data, item.getData(notNeedCls));
					}
				});
			}

			return data;
		},
		setData: function(data, notNeedCls) {
			if (this.isForm) {
				this.items.each(function(item) {
					var cls = item.clsName, name = item.clsParam;

					if ((CS.isNull(cls) || notNeedCls == true) && CS.isNotNull(data[name])) {
						item.setData(data[name]);
					} else if (CS.isNotNull(data[cls]) && CS.isNotNull(data[cls][name])) {
						item.setData(data[cls][name]);
					}
				});
			} else {
				Ext.each(this.children(), function(item) {
					if (CS.isNotNull(item.setData)) {
						item.setData(data, notNeedCls);
					}
				});
			}
		},
		clear: function() {
			Ext.each(this.children(), function(item) {
				if (CS.isNotNull(item.clear)) {
					item.clear();
				}
			});
		},
		setReadOnly: function(readOnly) {
			if (CS.isNull(readOnly)) {
				readOnly = true;
			}

			Ext.each(this.children(), function(item) {
				if (CS.isNotNull(item.setReadOnly)) {
					item.setReadOnly(readOnly);
				}
			});
		}
	}

});
